package com.travelsmart.client.apresentacao.screen;


import java.util.Date;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.travelsmart.client.apresentacao.image.ImagesResource;
import com.travelsmart.client.apresentacao.widget.FormDate;
import com.travelsmart.client.control.AdminServiceAsync;


public class ScreenHome extends BaseScreen{
	

	
	public ScreenHome(){
		exec();
	}


	@Override
	public void exec() {
		panelScreen.clear();
		final HorizontalPanel homePanel = new HorizontalPanel();
		Label lastUpdatedLabel;
		homePanel.setWidth("100%");
		Image logo = new Image(ImagesResource.INSTANCE.logo());
		logo.setWidth("500px");
		homePanel.add(logo);
		lastUpdatedLabel = new Label(FormDate.dateFormat.format(new Date()));
		homePanel.add(lastUpdatedLabel);
		AdminServiceAsync.service.getUserName(new AsyncCallback<String>() {
			
			@Override
			public void onSuccess(String result) {
				homePanel.add(new Label(result));
				
			}
			
			@Override
			public void onFailure(Throwable caught) {
				// TODO Auto-generated method stub
				
			}
		});
		lastUpdatedLabel.setWidth("300px");
		lastUpdatedLabel.setStyleName("gwt-Label-StockWatcher");
		panelScreen.add(homePanel);
	}
}
